//
//  NewPersonInfoViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/15.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewPersonInfoViewController.h"
#import "JTCSM.h"
#import "MyInfoView.h"
#import "MyDoubleLabelView.h"
#import "NewShangJiaRenZhengViewController.h"
#import "NewShenFenRenZhengViewController.h"
#import "NewMyErWeiMaViewController.h"
#import "NewHuiYuanViewController.h"

static CGFloat myinfoHeight = 50;
@interface NewPersonInfoViewController ()<UINavigationControllerDelegate>
{
    UIImageView *headerImageView;
}
@property (nonatomic,strong) UIImageView *logoImageV;
@property (nonatomic,strong) MyDoubleLabelView *bottomDoubleView;
@end

@implementation NewPersonInfoViewController
- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}

// 将要显示控制器
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 判断要显示的控制器是否是自己
    BOOL isShowHomePage = [viewController isKindOfClass:[self class]];
    [self.navigationController setNavigationBarHidden:isShowHomePage animated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    self.navigationController.delegate = self;
}
- (void)viewDidLoad {
    
    [super viewDidLoad];
    [df isRemoveTarbar:YES];
   
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    headerImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, KCONTROLLERWith, KCONTROLLERWith*0.6667)];
    headerImageView.image = [UIImage imageNamed:@"个人信息_背景.png"];
    [self.view addSubview:headerImageView];
    UIImage * firstImage = [UIImage imageNamed:@"fanhui.png"];
    CGRect firstFrame = CGRectMake(20, 20, 50, 44);
    CGFloat width = firstFrame.size.width;
    CGFloat height = firstFrame.size.height;
    CGFloat imagesize = 20;
    UIButton * leftButton = [[UIButton alloc]initWithFrame:firstFrame];
    [leftButton setImage:firstImage forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(gotBack) forControlEvents:UIControlEventTouchUpInside];
    leftButton.imageEdgeInsets = UIEdgeInsetsMake((height-imagesize)/2, 0, (height-imagesize)/2, (width-imagesize));
    [self.view addSubview:leftButton];
    UILabel *titleLabel = [UILabel initWithFrame:CGRectMake(0, 20, KCONTROLLERWith, 44) text:@"个人信息" font:20 textAlignment:NSTextAlignmentCenter texcolor:RGBACOLOR(51, 51, 51, 1) backgroundColor:nil];
    [self.view addSubview:titleLabel];
    
    CGFloat logoImageVSize = 80*[JTCSMSingle shareSingle].adaptationNumber;
    self.logoImageV = [[UIImageView alloc]initWithFrame:CGRectMake((KCONTROLLERWith-logoImageVSize)/2, 80, logoImageVSize, logoImageVSize)];
    self.logoImageV.image = [UIImage imageNamed:@"个人信息_头像.png"];
    [headerImageView addSubview:self.logoImageV];
    
    self.bottomDoubleView = [[MyDoubleLabelView alloc]initWithFrame:CGRectMake(0, KVIEW_Y(_logoImageV)+30*[JTCSMSingle shareSingle].adaptationNumber, headerImageView.LC_width, headerImageView.LC_height-(_logoImageV.LC_x+_logoImageV.LC_height)) titleFontsize:16 titlecolor:[df colorWithHexString:@"333333" alpha:1] contentFontsize:14 contentcolor:[df colorWithHexString:@"333333" alpha:1]];
    [headerImageView addSubview:self.bottomDoubleView];
    [self.bottomDoubleView InsertSpacesetvalueWithModel:@{KDoubleLabelTitle:@"李佳伟",KDoubleLabelContent:@"133****0395"} changeLabelY:12];
    
    [self layoutZhuzhaungTu];
    
    // Do any additional setup after loading the view.
}


- (void)layoutZhuzhaungTu{
    
    NSArray *array = @[@"天使会员"];
    NSArray *iamgearray = @[@"个人信息_会员.png"];
    NSArray *array1 = @[@"身份认证",@"商家认证"];
    NSArray *imagearray1 = @[@"个人信息_身份证.png",@"个人信息_商家认证.png"];
    NSArray *array2 = @[@"我的二维码"];
    NSArray *imagearray2 = @[@"个人信息_二维码.png"];
    for (int i = 0; i < array.count; i++) {
        MyInfoView *view1 = [[MyInfoView alloc]initWithFrame:CGRectMake(0, KVIEW_Y(headerImageView)+myinfoHeight*i, KCONTROLLERWith, myinfoHeight) imagename:iamgearray[i] title:array[i]placeholder:nil isShowLabel:ImageandlabelViewType radioBtnIndex:0 GroupId:@""];
        view1.tag = 100+i;
        view1.userInteractionEnabled = YES;
        [self.view addSubview:view1];
        view1.footerLabel.textColor = KZhuTiRGB;
        view1.footerLabel.text = @"提升";
        [df addTapGestureRecognizerWithTarget:self action:@selector(gotoAboutVC:) andaddView:view1];
    }
    [df lineViewWithHeightofTop:KVIEW_Y(headerImageView)+myinfoHeight*array.count+10 superView:self.view spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:10];
    for (int i = 0; i < array1.count; i++) {
        MyInfoView *view2 = [[MyInfoView alloc]initWithFrame:CGRectMake(0, KVIEW_Y(headerImageView)+myinfoHeight*array.count+10+myinfoHeight*i, KCONTROLLERWith, myinfoHeight) imagename:imagearray1[i] title:array1[i]placeholder:nil isShowLabel:ImageandlabelViewType radioBtnIndex:0 GroupId:@""];
        view2.tag = 200+i;
        view2.userInteractionEnabled = YES;
        [self.view addSubview:view2];
        view2.lineView.hidden=(i == array1.count-1?YES:NO);
        [df addTapGestureRecognizerWithTarget:self action:@selector(gotoAboutVC:) andaddView:view2];
    }
    [df lineViewWithHeightofTop:KVIEW_Y(headerImageView)+myinfoHeight*(array.count+array1.count)+20 superView:self.view spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:10];
    for (int i = 0; i < array2.count; i++) {
        MyInfoView *view3 = [[MyInfoView alloc]initWithFrame:CGRectMake(0, KVIEW_Y(headerImageView)+myinfoHeight*(array.count+array1.count)+20+myinfoHeight*i, KCONTROLLERWith, myinfoHeight) imagename:imagearray2[i] title:array2[i]placeholder:nil isShowLabel:ImageandlabelViewType radioBtnIndex:0 GroupId:@""];
        view3.tag = 300+i;
        view3.userInteractionEnabled = YES;
        [self.view addSubview:view3];
        [df addTapGestureRecognizerWithTarget:self action:@selector(gotoAboutVC:) andaddView:view3];
    }
}
- (void)gotoAboutVC:(UITapGestureRecognizer *)tap{
    NSInteger tagnumber = [tap view].tag;
    switch (tagnumber) {
        case 100:
            [self gotoNewHuiYuanVC];
            break;
        case 200:
            [self gotoNewShenFenRenzhengVC];
            break;
        case 201:
            [self gotoNewShangJiaRenZhengVC];
            break;
        case 300:
            [self gotoNewMyErWeiMaVC];
        default:
            break;
    }
}
- (void)gotoNewHuiYuanVC{
    NewHuiYuanViewController *vc = [[NewHuiYuanViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)gotoNewShangJiaRenZhengVC{
    NewShangJiaRenZhengViewController *vc = [[NewShangJiaRenZhengViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)gotoNewShenFenRenzhengVC{
    NewShenFenRenZhengViewController *vc = [[NewShenFenRenZhengViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)gotoNewMyErWeiMaVC{
    NewMyErWeiMaViewController *vc = [[NewMyErWeiMaViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
